import CryptoJS from 'crypto-js'
const keyStr = 'cboard'
// 解密
export const Decrypt = function (val) {
    const key  = CryptoJS.enc.Utf8.parse(keyStr);
    const WordArray = CryptoJS.enc.Hex.parse(val);
    const base64str = CryptoJS.enc.Base64.stringify(WordArray);
    const decrypt = CryptoJS.AES.decrypt(base64str, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}
// 加密
export const Encrypt = function (val) {
    const key  = CryptoJS.enc.Utf8.parse(keyStr);
    const srcs = CryptoJS.enc.Utf8.parse(val);
    const encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
    return encrypted.ciphertext.toString().toUpperCase();
}
